FROM centos:7

#install libs php nginx
RUN mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup \
	&& curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo \
	&& sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo \
    && yum install gcc gcc-c++ autoconf make libxml2-devel sqlite-devel libcurl-devel libpng-devel libjpeg-devel freetype-devel libzip-devel openssl-devel bzip2 pcre-devel curl git wget unzip zip -y \
	&& yum -y install epel-release \
	&& yum -y install oniguruma oniguruma-devel \
	&& cd /opt/ \
	&& wget https://www.php.net/distributions/php-7.4.24.tar.bz2 \
	&& tar -xjvf php-7.4.24.tar.bz2 \
	&& cd php-7.4.24 \
	&& ./configure --prefix=/usr/local/php7.4 --with-config-file-path=/usr/local/php7.4/etc --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-gd --enable-mbstring --enable-session --with-iconv --with-mhash --with-gettext --enable-bcmath --with-zlib-dir --enable-sockets --enable-shmop --enable-static --with-curl --enable-fpm --enable-soap --enable-opcache --with-jpeg --with-freetype --with-openssl --with-zlib \
	&& make && make install \
	&& cp /usr/local/php7.4/etc/php-fpm.conf.default /usr/local/php7.4/etc/php-fpm.conf \
	&& cd /usr/local/php7.4/etc/ \
	&& wget https://gitee.com/thomas408003146/docs/raw/master/php.ini \
	&& cd /usr/local/php7.4/etc/php-fpm.d \
	&& wget https://gitee.com/thomas408003146/docs/raw/master/www.conf \
	&& ln -s /usr/local/php7.4/bin/php /usr/bin/php \
    && ln -s /usr/local/php7.4/bin/phpize /usr/bin/phpize \
    && ln -s /usr/local/php7.4/bin/php-config /usr/bin/php-config \
	&& cp /opt/php-7.4.24/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm7.4 \
	&& chmod +x /etc/init.d/php-fpm7.4 \
	&& cd /opt/ \
	&& wget https://pecl.php.net/get/redis-5.3.4.tgz \
	&& tar -xzvf redis-5.3.4.tgz \
	&& cd redis-5.3.4 \
	&& phpize --with-php-config=php-config \
	&& ./configure \
	&& make && make install \
	&& cd /opt \
	&& wget https://pecl.php.net/get/swoole-4.7.1.tgz \
	&& tar -xzvf swoole-4.7.1.tgz \
	&& cd swoole-4.7.1 \
	&& phpize --with-php-config \
	&& ./configure \
	&& make && make install \
	&& cd /opt \
	&& wget --no-check-certificate https://openresty.org/download/openresty-1.19.9.1.tar.gz \
	&& tar -xzvf openresty-1.19.9.1.tar.gz \
	&& cd openresty-1.19.9.1 \
	&& ./configure \
	&& make && make install \
	&& ln -s /usr/local/openresty/nginx/sbin/nginx /usr/bin/nginx \
	&& cd /usr/local/openresty/nginx/conf \
	&& rm -f nginx.conf \
	&& wget https://gitee.com/thomas408003146/docs/raw/master/nginx.conf \
	&& mkdir sites \
	&& cd sites \
	&& wget https://gitee.com/thomas408003146/docs/raw/master/samlemall.conf \
	&& cd /opt \
	&& curl -sS https://getcomposer.org/installer | php \
    && mv composer.phar /usr/bin/composer && chmod +x /usr/bin/composer \
	&& composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ \
	&& rm -rf /opt/* \
	&& mkdir -p /data \
	&& cd /etc/init.d \
	&& wget https://gitee.com/thomas408003146/docs/raw/master/start.sh \
	&& chmod +x start.sh \
	&& useradd www \
	&& chown -R www:www /data
	
WORKDIR /data
EXPOSE 80